package com.tacc.tyun.model;

import com.tacc.tyun.base.BaseConstant;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
* 导航菜单
* @author congcong tao
* @date 2017/8/9 10:44
*/
@Table(name = "msg_menu")
public class MsgMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "menuId")
    private String menuId;//主键

    private String name;//名称

    @Column(name = "leafTag")
    private String leafTag;//是否叶子节点1=是即父节点，0=否

    @Column(name = "grade")
    private Integer grade;//1=1级，2=2级

    @Column(name = "type")
    private String type;//类型1：微信 2：PC端

    @Column(name = "menuParentId")
    private String menuParentId;//父类id

    @Column(name="url")
    private String msgUrl;//跳转链接

    private String creator;

    @Column(name = "createTime")
    private Date createTime;

    @Column(name = "updateTime")
    private Date updateTime;

    @Column(name = "removeTag")
    private Integer removeTag;

    @Transient
    private List<MsgMenu> children=new ArrayList<MsgMenu>();

    //tree
    public Boolean getIsParent() {//父节点是true，否则false
        return StringUtils.equals(getLeafTag(), BaseConstant.MSG_MENU_IS_LEAFTAG) ;
    }

    public String getId(){
        return getMenuId();
    }

    public String getpId(){
        return getMenuParentId();
    }

    public String getMenuId() {
        return menuId;
    }

    public void setMenuId(String menuId) {
        this.menuId = menuId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLeafTag() {
        return leafTag;
    }

    public void setLeafTag(String leafTag) {
        this.leafTag = leafTag;
    }

    public Integer getGrade() {
        return grade;
    }

    public void setGrade(Integer grade) {
        this.grade = grade;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMenuParentId() {
        return menuParentId;
    }

    public void setMenuParentId(String menuParentId) {
        this.menuParentId = menuParentId;
    }

    public String getMsgUrl() {
        return msgUrl;
    }

    public void setMsgUrl(String msgUrl) {
        this.msgUrl = msgUrl;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getRemoveTag() {
        return removeTag;
    }

    public void setRemoveTag(Integer removeTag) {
        this.removeTag = removeTag;
    }

    public List<MsgMenu> getChildren() {
        return children;
    }

    public void setChildren(List<MsgMenu> children) {
        this.children = children;
    }
}